package com.changgou.goods.dao;

import com.changgou.pojo.Sku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

/**
* @Author: 少迪
* @Date: Created in 2019-08-09 11:15
* @Description:
* @Version: 1.0
*/

public interface SkuMapper extends Mapper<Sku> {

    /**
     * 扣减商品库存
     * @param id
     * @param num
     */
    @Select( "update tb_sku set num=num-#{num} where id=#{id}" )
    void deductionStock(@Param( "id" ) String id, @Param( "num" ) Integer num );


    /**
     * 增加商品销量
     * @param id
     * @param num
     */
    @Select( "update tb_sku set sale_num=sale_num+#{num} where id=#{id} " )
    void addSaleNum(@Param( "id" ) String id, @Param( "num" ) Integer num );
}
